<!-- components/Account.vue -->
<template>
	<view class="container">
		<!-- 标题 -->
		<!-- <CustomNavbar title="出售积分"/> -->
		<view class="content">
			<view class="tab">
				<view class="tab_li" :class="{active: formData.publish_type == 0}" @click="formData.publish_type = 0">出售</view>
				<view class="tab_li" :class="{active: formData.publish_type == 1}" @click="formData.publish_type = 1">求购</view>
			</view>
			<view class="transfer-num box">
				<text>{{formData.publish_type ? '求购' : '出售'}}积分数量</text>
				<input type="number" :placeholder="'请输入'+(formData.publish_type ? '求购' : '售卖')+'数量'"  placeholder-class="placeholder" v-model="formData.score" style="text-align: left;"/>
			</view>
			<view class="transfer-num box flex-between">
				<text>{{formData.publish_type ? '求购' : '售卖'}}价格</text>
				<input type="text" :placeholder="'请输入'+(formData.publish_type ? '求购' : '售卖')+'价格'"  placeholder-class="placeholder" v-model="formData.price" style="margin-top: 0;flex:1;text-align: right;" />
				<text style="margin-left: 10rpx;">元</text>
			</view>
			<view class="presented box">
				<view class="transfer-num box">	
					<text>标题</text>
					<textarea name="" id="" cols="20" rows="10" maxlength="30" placeholder="请输入标题(限制30个字以内)" placeholder-class="placeholder" v-model="formData.title"></textarea>
				</view>
				<view class="line">
					
				</view>
				<view class="flex-between">
					<text>支付密码</text>
					<input type="password" placeholder="请输入支付密码" placeholder-class="placeholder" v-model="formData.pay_password" />
				</view>
			</view>
			<view class="desc" v-html="desc"></view>
			
			<button @click="query">确认提交</button>
		</view>
	</view>
</template>

<script setup>
	import {ref,reactive} from 'vue'
	import CustomNavbar from '@/components/CustomNavbar.vue';
	const formData = reactive({
		score:'',
		title:'',
		price: 0,
		pay_password:'',
		publish_type: 0
	})
	const desc = ref('')
	uni.$api.score.scoreDesc().then(res => {
		if(res.code == 200){
			desc.value = res.data.desc
		}
	})
	// 确认
	const query = ()=>{
		uni.$api.score.scoreAdd(formData).then(res => {
			if (res.code == 200) {
				uni.showToast({
					title: res.msg
				})
				setTimeout(function(){
					formData.score = '';
					formData.title = '';
					formData.price = '';
					formData.pay_password = '';
				},1000)
				
			}
		})
	}
</script>

<style lang="scss" scoped>
	.container {
		
		background: url('/static/index_slices/index_bg.png') no-repeat;
		background-size: 100% auto;
		padding-top: 28rpx;
		
		
		.tab {
			display: flex;
			align-items: center;
			justify-content: center;
			margin: 0 auto 40rpx;
			background-color: white;
			border-radius: 20rpx;
			width: 400rpx;
			font-size: 38rpx;
		
			.tab_li {
				flex: 1;
				display: flex;
				align-items: center;
				justify-content: center;
				color: #666;
				font-size: 0.875rem;
				width: 10.78125rem;
				line-height: 85rpx;
				position: relative;
		
				&.active {
					color: black;
					font-weight: bold;
				}
		
				&.active::after {
					display: block;
					content: '';
					width: 1.25rem;
					transition-duration: 300ms;
					height: 3px;
					background: 0% 0% / cover rgb(253, 56, 50);
					position: absolute;
					bottom: 10rpx;
					left: 50%;
					transform: translateX(-50%);
				}
			}
		}
		
		/* 导航栏高度 */
		.content{
			padding: 20rpx;
			padding-bottom: 50rpx;
			.box{
				border-radius: 10rpx;
				background-color: #fff;
				
				color: #101624;
				font-size: 28rpx;
				font-weight: bold;
				input{
					font-weight: normal;
					font-size: 28rpx;
					text-align: right;
				}
				.placeholder{
					color: #C5C9D2;
					
				}
				
			}
			.transfer-num{
				margin-bottom: 16rpx;
				padding: 39rpx 30rpx 48rpx;
				input,textarea{
					margin-top: 39rpx;
					width: 100%;
					max-height: 100rpx;
				}
			}
			.presented{
				.line{
					width: 100%;
					height: 1px;
					background-color: #EFEFEF;
				}
				.flex-between{
					padding: 42rpx 30rpx;
					input{
						width: 250rpx;
					}
				}
			}
			.describe{
				margin-top: 54rpx;
				font-size: 24rpx;
				color: #898989;
				h4{
					color: #666666;
					position: relative;
					padding-left: 20rpx;
					font-size: 28rpx;
					margin-bottom: 30rpx;
					&::after{
						content: '';
						display: block;
						position: absolute;
						width: 10rpx;
						height: 26rpx;
						border-radius: 5rpx;
						background-color: #FD3933;
						left: 0;
						top: 8rpx;
						
					}
				}
				text{
					line-height: 50rpx;
				}
				
			}
			// 确认按钮
			button{
				// position: absolute;
				// left: 30rpx;
				bottom: 30rpx;
				width: 690rpx;
				height: 88rpx;
				line-height: 88rpx;
				border-radius: 44rpx;
				color: #fff;
				background: linear-gradient(to right,#FF5A55,#FD3832);
				margin: 0 auto;
			}
			.desc{
				margin: 40rpx 0 80rpx;
				color: #666;
			}
		}
	}
</style>